/**
 * <p>Copyright (R) 2014 正方软件股份有限公司。<p>
 */
package com.zfsoft.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;


//HandlerMethodReturnValueHandler
@Controller
@RequestMapping("r")
public class ReturnValueController {
	
	//ViewNameMethodReturnValueHandler
	@RequestMapping(path="index")
	public String index() {
		return "index";
	}

	//ModelAndViewMethodReturnValueHandler
	@RequestMapping(path="responseModelAndView")
	public ModelAndView responseModelAndView() {
		ModelAndView modelAndView = new ModelAndView("index");
		return modelAndView;
	}
	
	//ViewMethodReturnValueHandler
	@RequestMapping(path="responseView")
	public View responseView() {
		//
		return null;
	}
	
	//MapMethodProcessor
	@RequestMapping(path="responseMap")
	public Map<String,String> responseMap(){
		Map<String,String> map = new HashMap<String,String>();
		return map;
	}
	
	//RequestResponseBodyMethodProcessor
	@ResponseBody
	@RequestMapping(path="responseString")
	public String responseString() {
		return "responseString";
	}
	
	//StreamingResponseBodyReturnValueHandler
	//ResponseEntity
	@ResponseBody
	@RequestMapping(path="responseStreamingResponseBody")
	public StreamingResponseBody responseStreamingResponseBody() {
		StreamingResponseBody body = new StreamingResponseBody() {

			@Override
			public void writeTo(OutputStream outputStream) throws IOException {
				
			}
		};
		return body;
	}
	
	//HttpHeadersReturnValueHandler
	@ResponseBody
	@RequestMapping(path="responseHttpHeaders")
	public HttpHeaders responseHttpHeaders() {
		HttpHeaders httpHeaders = new HttpHeaders();
		httpHeaders.add(HttpHeaders.ACCEPT_CHARSET, "utf-8");
		return httpHeaders;
	}
}
